package com.example.demo.config;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * netty启动类
 */
@Component
public class NetteyBooter implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (contextRefreshedEvent.getApplicationContext().getParent()==null){

            try {
                WebSocketConfig.getInstance().start();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
